{%TEMPLATE->struct/head%}
{%TEMPLATE->struct/menu%}
<h2>Manage API Key</h2>
{%TEMPLATE->struct/messages%}
<form action='api.php?keyId=[[key.getId()]]' method='post'>
	<input type='hidden' name='action' value='[[$DApiAction::EDIT_KEY]]'>
	<input type="hidden" name="csrf" value="[[csrf]]">
  <input type="hidden" name="keyId" value="[[key.getId()]]">
	<div class="card">
    <div class="table-responsive">
      <table class="table table-bordered">
			  <tr>
				  <th>User</th>
				  <td>
					  <select class="form-control" name="userId" title="User">
              <option value="">---</option>
              {{FOREACH user;[[users]]}}
                <option value="[[user.getId()]]"{{IF [[user.getId()]] == [[key.getUserId()]]}} selected{{ENDIF}}>[[user.getUsername()]]</option>
              {{ENDFOREACH}}
            </select>
				  </td>
			  </tr>
        <tr>
          <th>API Access Group</th>
          <td>
            <select class="form-control" name="groupId" title="Group">
              <option value="">---</option>
              {{FOREACH group;[[groups]]}}
                <option value="[[group.getId()]]" {{IF [[group.getId()]] == [[key.getApiGroupId()]]}} selected{{ENDIF}}>[[group.getName()]]</option>
              {{ENDFOREACH}}
            </select>
          </td>
        </tr>
        <tr>
          <th>Validity Start</th>
          <td>
            <input type="datetime-local" value="[[date('Y-m-d\TH:i:s', [[key.getStartValid()]])]]" class="form-control" name="startValid">
          </td>
        </tr>
        <tr>
          <th>Validity End</th>
          <td>
            <input type="datetime-local" value="[[date('Y-m-d\TH:i:s', [[key.getEndValid()]])]]" class="form-control" name="endValid">
          </td>
        </tr>
        <tr>
          <th>Access Count</th>
          <td>[[key.getAccessCount()]]</td>
        </tr>
        <tr>
          <th>Access Key</th>
          <td><pre>[[key.getAccessKey()]]</pre></td>
        </tr>
			  <tr>
				  <td colspan='2'>
					  <input type='submit' class='btn btn-success' value='Save Changes'>
				  </td>
			  </tr>
		  </table>
    </div>
	</div>
</form>
{%TEMPLATE->struct/foot%}
